package com.example.tool.bean.business;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Date;

import static com.example.tool.util.DateUtil.FORMAT_YEAR_MONTH_DAY;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("ts_claims_info")
public class ClaimsInfoDO {
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    //物流单号
    @TableField("waybill_no")
    private String waybillNo;
    //订单备注
    @TableField("remarks")
    private String remarks;
    //店铺名称
    @TableField("shop_name")
    private String shopName;
    // 订单备注
    @JsonIgnore
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    // 年月日
    @TableField(exist=false)
    private String yyyyMMdd;
    @TableField("if_deleted")
    @TableLogic
    @JsonIgnore
    private Byte ifDeleted;

    public String getYyyyMMdd() {
        if (ObjectUtil.isNotNull(createTime)){
        return new SimpleDateFormat(FORMAT_YEAR_MONTH_DAY).format(createTime);
        }
        return "";
    }
}
